﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using App.MVC.Extend;
using ArxOne.MrAdvice.Advice;

namespace App.MVC.Attributes
{
    [Serializable]
    [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = true)]
    public class RunningLogAspect : Attribute, IMethodAdvice
    {
        /// <summary>
        /// 方法名称
        /// </summary>
        public string MethodName { set; get; }
        public void Advise(MethodAdviceContext context)
        {
            if (string.IsNullOrEmpty(MethodName))
            {
                MethodName = context.TargetName;
            }
            //执行之前
            LogHelper.WriteLog_Sql(MethodName + "开始" + "时间：" + DateTime.Now);
            context.Proceed();
            LogHelper.WriteLog_Sql(MethodName + "结束" + "时间：" + DateTime.Now);
            //执行之后
        }
    }
}